import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileStream {
    public static void main(String[] args) {

    }

    @Test
    public void test() {
        File file = new File("pic3.jpg");
        File copyFile = new File("pic3_copy.jpg");
        try(FileInputStream fis = new FileInputStream(file);
            FileOutputStream fos = new FileOutputStream(copyFile)) {
            int len;
            byte[] buffer = new byte[1024];
            while ((len = fis.read(buffer)) != -1) {
                fos.write(buffer, 0, len);
            }
            System.out.println("复制成功");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
